#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include "create_xml.h"

void create_xml(int num)
{
	FILE *fp = fopen("Studentsystem.xml","w");
	assert(fp != NULL);

	fprintf(fp,"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n");
	fprintf(fp,"<system>\n");
	for(int i = 0; i < num; i++)
	{
		fprintf(fp,"	<student>\n");
		fprintf(fp,"		<ID>%d</ID>\n",student[i].ID);
		fprintf(fp,"		<name>%s</name>\n",student[i].name);
		fprintf(fp,"		<sex>%s</sex>\n",student[i].sex);
		fprintf(fp,"		<achi>\n");
		fprintf(fp,"			<chinese>%d</chinese>\n",student[i].chinese);
		fprintf(fp,"			<math>%d</math>\n",student[i].math);
		fprintf(fp,"			<english>%d</english>\n",student[i].english);
		fprintf(fp,"		</achi>\n");
		fprintf(fp,"	</student>\n");
	}
	fprintf(fp,"</system>\n");

	fclose(fp);
}
